package service;

import java.util.List;

import dao.CustomerDao;
import dao.DrugDao;
import dao.OrderDao;
import entity.Customer;
import entity.Drug;
import entity.Order;
import util.PageTools;

public class OrderService {
    private OrderDao orderDao=new OrderDao();
    private DrugDao drugDao=new DrugDao();
    private CustomerDao customerDao=new CustomerDao();
	
	public boolean insertOrder(Order order) {
		return orderDao.insertOrder(order);
	}
	public boolean deleteOrderByOid(int oid) {
		return orderDao.deleteOrderByOid(oid);
	}
	public List<Order> showOrder(){
		return orderDao.selectOrder();
	}
	public int counts() {
		return orderDao.counts();
	}
	public List<Order> showOrderByPage(PageTools pt){
		 List<Order> list=orderDao.selectOrderByPage(pt);
		   for(Order  r:list)
		   {
			    String did=r.getDid();
			    Drug drug=drugDao.selectDrugByDid(did);
			    r.setDname(drug.getDname());
			    //System.out.println("===============");
			    //System.out.println(r.getDname());
			    int cid=r.getCid();
			    Customer customer=customerDao.selectCustomerByCid(cid);
			    r.setCname(customer.getCname());
			    //System.out.println("===============");
			    //System.out.println(r.getCname());
		   }   
		   System.out.println(list);
			   
		   return list;
	}
	public Order showOrderByOid(int oid) {
		return orderDao.selectOrderByOid(oid);
	}
	public boolean updateOrder(Order order) {
		return orderDao.updateOrder(order);
	}


}
